<?php
require('../kernel/config.php');
require(PATH_ABS.'/admin/login.php');
$o_db = dbConnect::getInstance();
$o_post  = new ABPost($o_db);
$o_tpl=  new ABTemplate('admin/index', 'comment');

if(isset($_GET['delete'])){
	$o_TPL->set('adelete', true);
	$o_TPL->set('pid', (int)$_GET['delete']);
}elseif(isset($_GET['erase'])){
	if(is_numeric($_GET['erase'])){
		$o_DBCom = new dbComments($_CONF['server'], $_CONF['user'], $_CONF['keypass'], $_CONF['dbname']);
		if($o_DBCom->delete($_GET['erase'])){
			$o_TPL->set('ok', 'Comentario eliminado correctamente');
		}else{
			$o_TPL->set('error',  'Error al tratar de eliminar el comentario');
		}
	}else{
		$o_TPL->set('error',  'El identificador pasado no es válido');
	}
}elseif(isset($_POST['moderate'])){
	$o_DBCom = new dbComments($_CONF['server'], $_CONF['user'], $_CONF['keypass'], $_CONF['dbname']);
	$o_TPL->set('cmoderate', $o_DBCom->toindex($_POST['postid']));
}elseif(isset($_GET['nospam'])){
	if(is_numeric($_GET['nospam'])){
		$o_DBCom = new dbComments($_CONF['server'], $_CONF['user'], $_CONF['keypass'], $_CONF['dbname']);
		if($o_DBCom->nospam($_GET['nospam'])){
			$o_TPL->set('ok', 'Quitada la clasificación de Spam');
		}else{
			$o_TPL->set('error',  'Error al tratar de quitar la clasificación de Spam');
		}
	}else{
		$o_TPL->set('error',  'El identificador pasado no es válido');
	}
}

$o_tpl->comments = '';
$o_tpl->ptitle = 'Comentarios';
ABApi::setCommonAdmin($o_tpl);
$o_tpl->parse();
?>
